<?php
    $connection = mysql_connect('localhost', 'panospet', 'meipei2c');
    if (!$connection) {
        die('Could not connect: ' . mysql_error());
    }						
    mysql_query("SET NAMES utf8");
    mysql_select_db("panospet");


    $query = "SELECT * FROM ukol8_wizzard ";
    $result = mysql_query($query);
    if (!$result) {
        die('Chyba ve spusteni dotazu: ' . mysql_error());
    }
    mysql_close($connection);
?>
<!DOCTYPE html>
<html>
<head>
<title>Úkol 8</title>
<meta charset="utf-8">
<style>
    body 
    {
        background: #0D48A7;
        font-family: Georgia, Times, serif;
        color: white;
    } 
    #body
    {
        background: #4079D3;
        min-width: 500px;
        width: 70%;
        position: relative;
        margin: 0px auto;
        text-align: center;
    }
    #header
    {
        background: #042D6D;
    }
    #footer
    {
        background: #042D6D;
    }
    table 
    {
        
        margin: 10px auto;
    }
    #menu a
    {
        color: white;
        margin-left: 2em
    } 
</style>
</head>
<body>
    <div id="body">
        <div id="header">
            <h1>WIZZARD</h1>    
        </div>
        <div id ="menu">
            <?php require 'menu.php'; ?>
        </div>
        <div id="content">
        	<h2>Síň slávy</h2>
                <?php 
                if($result)
                {	
                    echo "<table>";
                    echo "<tr>";
                    echo "<th>Datum</th>";
                    echo "<th>Jméno</th>";
                    echo "<th>Počet piv</th>";
                    echo "<th>‰</th>";
                    while ($row = mysql_fetch_array($result)) 
                    {
                        $zaznam = true;
                        echo "<tr>";
                            echo "<td>".$row['date']."</td>";
                            echo "<td>".$row['username']."</td>";
                            echo "<td>".$row['beer_count']."</td>";
                            echo "<td>".$row['alcohol']."</td>";
                        echo "</tr>";
                    }
                    echo "</table>";


                    if(!$zaznam)
                    {
                        echo "<p>Žádná měření</p>";
                    }
                }
                ?>
        </div>
        <div id="footer">
            <p>&not;&copy;&sup2; Petr Panoška</p>
        </div>
    </div>
</body>
</html>